package net.gdface.facelog;

import java.util.Date;

/**
 * 临时密码作用目标描述对象<br>
 * 临时密码用于为设备提供临时的访问权限
 * @author guyadong
 *
 */
public class TmpwdTargetInfo implements CommonConstant{
	private TmpPwdTargetType targetType;
	private int targetId;
	private Date expiryDate;
	public TmpwdTargetInfo() {
	}
	
	public TmpwdTargetInfo(TmpPwdTargetType targetType, int targetId, Date expiryDate) {
		super();
		this.targetType = targetType;
		this.targetId = targetId;
		this.expiryDate = expiryDate;
	}

	public TmpPwdTargetType getTargetType() {
		return targetType;
	}
	public void setTargetType(TmpPwdTargetType targetType) {
		this.targetType = targetType;
	}
	/**
	 * 返回临时密码作用目标类型<br>
	 * 此字段用于定义 {@link #targetId}的类型
	 * <ul>
	 * <li>0 user group id</li>
	 * <li>1 device group id</li>
	 * <li>2 user id</li>
	 * <li>3 device id</li>
	 * </ul>
	 * @return
	 */
	public int getTargetId() {
		return targetId;
	}
	public void setTargetId(int targetId) {
		this.targetId = targetId;
	}
	public Date getExpiryDate(){
		return expiryDate;
	}
	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + targetId;
		result = prime * result + ((targetType == null) ? 0 : targetType.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof TmpwdTargetInfo))
			return false;
		TmpwdTargetInfo other = (TmpwdTargetInfo) obj;
		if (targetId != other.targetId)
			return false;
		if (targetType != other.targetType)
			return false;
		return true;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("TmpwdTargetInfo [targetType=");
		builder.append(targetType);
		builder.append(", targetId=");
		builder.append(targetId);
		builder.append("]");
		return builder.toString();
	}

}
